#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,m,tmp; 
signed main()
{
	freopen("circ.in","r",stdin);
	freopen("circ.out","w",stdout);
	ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>t;
	while(t--)
	{
		cin>>n>>m;
		if(n<=m)
			cout<<0<<'\n';
		else
			cout<<1<<'\n';
		while(m--)
			cin>>tmp>>tmp;
	}
	return 0;
}

